<template>
  <div class="common-layout">
    <el-container>
      <!-- 侧边栏 -->
      <el-aside
        :style="{ width: asideWidth }"
        style="min-height: 100vh; background-color: #001529"
      >
        <div
          style="
            height: 60px;
            color: white;
            display: flex;
            align-items: center;
            justify-content: center;
          "
        >
          <img
            src="@/assets/logo.jpg"
            style="width: 40px; height: 40px; margin-right: 10px"
          />
          <span class="loge-title" v-show="!isCollapse">运动场管理系统</span>
        </div>

        <el-menu
          :collapse="isCollapse"
          :collapse-transition="false"
          background-color="#001529"
          text-color="rgba(255,255,255,0.65)"
          style="border: none"
          router
          :default-active="$route.path"
          class="el-menu-vertical-demo"
          @open="handleOpen"
          @close="handleClose"
          active-text-color="#ffd04b"
        >
          <!--router属性实现跳转 -->
          <el-menu-item index="/type">
            <el-icon><House /></el-icon>
            <span>首页</span>
          </el-menu-item>
          <el-sub-menu index="2">
            <template #title>
              <el-icon><Document /></el-icon>
              <span>文章管理</span></template
            >
            <el-menu-item index="2-1">文章列表</el-menu-item>
            <el-menu-item index="2-2">发布文章</el-menu-item>
          </el-sub-menu>
          <el-menu-item index="3">
            <el-icon><User /></el-icon>
            <span>用户管理</span>
          </el-menu-item>
          <el-menu-item index="4">
            <el-icon><Setting /></el-icon>
            <span>设置</span>
          </el-menu-item>
        </el-menu>
      </el-aside>

      <el-container>
        <!-- 头部 -->
        <el-header>
          <el-icon
            class="collapseIcon"
            style="font-size: 26px"
            @click="tCollapse"
            ><Fold
          /></el-icon>

          <el-breadcrumb :separator-icon="ArrowRight" style="margin-left: 20px">
            <el-breadcrumb-item :to="{ path: '/' }"
              >TypeView</el-breadcrumb-item
            >
            <el-breadcrumb-item>promotion management</el-breadcrumb-item>
            <el-breadcrumb-item>promotion list</el-breadcrumb-item>
            <el-breadcrumb-item>promotion detail</el-breadcrumb-item>
          </el-breadcrumb>

          <div
            style="
              flex: 1;
              width: 0;
              display: flex;
              align-items: center;
              justify-content: flex-end;
            "
          >
            <!-- <i Font class="el-icon-quanping" style="font-size: 26px;"></i> -->
            <el-icon style="font-size: 26px" @click="toggleFullScreen"
              ><FullScreen
            /></el-icon>
            <el-dropdown placement="bottom-end">
              <div style="display: flex; align-items: center; cursor: default">
                <img
                  src="@/assets/logo.jpg"
                  alt=""
                  style="width: 40px; height: 40px"
                />
                <span>管理员</span>
              </div>
              <template #dropdown>
                <el-dropdown-menu>
                  <el-dropdown-item>个人中心</el-dropdown-item>
                  <el-dropdown-item>修改密码</el-dropdown-item>
                  <el-dropdown-item @click="">退出登录</el-dropdown-item>
                </el-dropdown-menu>
              </template>
            </el-dropdown>
          </div>
        </el-header>

        <el-main>Main</el-main>
      </el-container>
    </el-container>
  </div>
</template>
<script setup>
import { useRouter } from "vue-router";
import { ArrowRight } from "@element-plus/icons-vue";
import { ref } from "vue";
import "@/assets/iconfont/iconfont.css";

const router = useRouter();
const isCollapse = ref(false);
const asideWidth = ref("200px");
const tCollapse = () => {
  isCollapse.value = !isCollapse.value;
  asideWidth.value = isCollapse.value ? "64px" : "200px";
  collapseIcon.value = isCollapse.value ? "Fold" : "Fold";
};
const handleOpen = (key, keyPath) => {
  console.log(key, keyPath);
};
const handleClose = (key, keyPath) => {
  console.log(key, keyPath);
};
const toggleFullScreen = () => {
  if (!document.fullscreenElement) {
    document.documentElement.requestFullscreen();
  } else {
    if (document.exitFullscreen) {
      document.exitFullscreen();
    }
  }
};
</script>
<style scoped>
.el-menu--inline .el-menu-item {
  background-color: #000c17 !important;
}
/* .el-sub-menu__title {
  color: #fff !important;
          } */
.el-menu-item:hover,
.el-sub-menu__title:hover {
  color: #fff !important;
}
.el-sub-menu__title:hover i {
  color: #fff !important;
}
.el-menu-item.is-active {
  background-color: #40a9ff !important;
}
.el-sub-menu__title.is-active {
  background-color: #40a9ff !important;
}
.el-sub-menu:hover .el-sub-menu__title {
  background-color: #40a9ff !important;
}
.el-menu-item:hover {
  background-color: #40a9ff !important;
}
.el-aside {
  transition: all 0.3s;
  box-shadow: 2px 0 6px rgb(0 21 41 / 35%);
}

.loge-title {
  margin-left: 5px;
  font-size: 20px;
  transition: all 0.5s;
}
.el-header {
  box-shadow: 2px 0 6px rgb(0 21 41 / 35%);
  display: flex;
  align-items: center;
}
</style>
